﻿namespace Parser

open Lexer

module Main =
    [<EntryPoint>]
    let rec main argv =
        match Array.tryHead argv with
        | None ->
            System.Console.WriteLine "输入词法分析器的输出文件路径:"
            main  [|System.Console.ReadLine()|]
        | Some path ->
            let lexerOutput =
                System.IO.File.ReadAllLines(path)
                |> Array.map Tocken.createTocken
                |> Array.toList


            let result = Parser.parser (lexerOutput)
            printfn "%-50s	%s" "栈" "操作"

            let rec output result =
                match result with
                | [] -> ()
                | x :: xs ->
                    match x with
                    | a, b -> printfn "%-50s	%s" a b

                    output xs

            output result
            System.Console.WriteLine "按任意键结束..."
            System.Console.ReadKey() |> ignore
            0
